<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.util.log.Logger</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.util.log.Logger");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461">tango.util.log.Logger</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
May 2004: Initial release<br><br>
<b>Version:</b><br>
Feb 2007: Switched to lazy expr<br><br>
<b>author:</b><br>Kris<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L86">Logger</a></span>
<script>explorer.outline.addDecl('Logger');</script> : ILevel; [public]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Loggers are named entities, sometimes shared, sometimes specific to 
        a particular portion of code. The names are generally hierarchical in 
        nature, using dot notation &#40;with '.'&#41; to separate each named section. 
        For example, a typical name might be something like "mail.send.writer"
        <pre class="d_code">

        <span class="k">import</span> <span class="i">tango</span>.<span class="i">util</span>.<span class="i">log</span>.<span class="i">Log</span>;
        
        <span class="k">auto</span> <span class="i">log</span> = <span class="i">Log</span>.<span class="i">getLogger</span> (<span class="sl">"mail.send.writer"</span>);

        <span class="i">log</span>.<span class="i">info</span>  (<span class="sl">"an informational message"</span>);
        <span class="i">log</span>.<span class="i">error</span> (<span class="sl">"an exception message: "</span> ~ <span class="i">exception</span>.<span class="i">toString</span>);

        <span class="i">etc</span> ...
        
</pre>
        
        It is considered good form to pass a logger instance as a function or 
        class-ctor argument, or to assign a new logger instance during static 
        class construction. For example: if it were considered appropriate to 
        have one logger instance per class, each might be constructed like so:
        <pre class="d_code">

        <span class="k">private</span> <span class="i">Logger</span> <span class="i">log</span>;
        
        <span class="k">static</span> <span class="k">this</span>()
        {
            <span class="i">log</span> = <span class="i">Log</span>.<span class="i">getLogger</span> (<span class="i">nameOfThisClassOrStructOrModule</span>);
        }
        
</pre></font><br><br>
<font color="black">Messages passed to a Logger are assumed to be pre-formatted. You 
        may find that the format&#40;&#41; methos is handy for collating various 
        components of the message: 
        <pre class="d_code">

        <span class="k">char</span> <span class="i">tmp</span>[<span class="n">128</span>] = <span class="k">void</span>;
        ...
        <span class="i">log</span>.<span class="i">warn</span> (<span class="i">log</span>.<span class="i">format</span> (<span class="i">tmp</span>, <span class="sl">"temperature is {} degrees!"</span>, <span class="n">101</span>));
        
</pre><br><br>        Note that a provided workspace is used to format the message, which 
        should generally be located on the stack so as to support multiple
        threads of execution. In the example above we indicate assignment as 
        "tmp = void", although this is an optional attribute &#40;see the language 
        manual for more information&#41;.<br><br>        To avoid overhead when constructing formatted messages, the logging
        system employs lazy expressions such that the message is not constructed
        unless the logger is actually active. You can also explicitly check to
        see whether a logger is active or not:
        <pre class="d_code">

        <span class="k">if</span> (<span class="i">log</span>.<span class="i">isEnabled</span> (<span class="i">log</span>.<span class="i">Level</span>.<span class="i">Warn</span>))
            <span class="i">log</span>.<span class="i">warn</span> (<span class="i">log</span>.<span class="i">format</span> (<span class="i">tmp</span>, <span class="sl">"temperature is {} degrees!"</span>, <span class="n">101</span>));
        
</pre><br><br>        You might optionally configure various layout &amp; appender implementations
        to support specific exact rendering needs.
        
        tango.log closely follows both the API and the behaviour as documented 
        at the official Log4J site, where you'll find a good tutorial. Those 
        pages are hosted over 
        <A HREF="http://logging.apache.org/log4j/docs/documentation.html">here</A>.<br><br></font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L95">trace</a></span>
<script>explorer.outline.addDecl('trace');</script>(lazy char[] <span class="funcparam">exp</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add a trace message. This is called 'debug' in Log4J but
                that is a  reserved word in the D language
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L103">info</a></span>
<script>explorer.outline.addDecl('info');</script>(lazy char[] <span class="funcparam">exp</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add an info message</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L111">warn</a></span>
<script>explorer.outline.addDecl('warn');</script>(lazy char[] <span class="funcparam">exp</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add a warning message</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L119">error</a></span>
<script>explorer.outline.addDecl('error');</script>(lazy char[] <span class="funcparam">exp</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add an error message</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L127">fatal</a></span>
<script>explorer.outline.addDecl('fatal');</script>(lazy char[] <span class="funcparam">exp</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add a fatal message</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L135">append</a></span>
<script>explorer.outline.addDecl('append');</script>(Level <span class="funcparam">level</span>, lazy char[] <span class="funcparam">exp</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Append a message to this logger via its appender list.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L144">format</a></span>
<script>explorer.outline.addDecl('format');</script>(char[] <span class="funcparam">buffer</span>, char[] <span class="funcparam">formatStr</span>, ...); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Format text using the formatter configured in the associated
                hierarchy &#40;see Hierarchy.setFormat&#41;</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L152">name</a></span>
<script>explorer.outline.addDecl('name');</script>(); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the name of this Logger</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Level <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L160">level</a></span>
<script>explorer.outline.addDecl('level');</script>(); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the current level assigned to this logger</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L180">setLevel</a></span>
<script>explorer.outline.addDecl('setLevel');</script>(Level <span class="funcparam">level</span> = Level.Trace); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set the activity level of this logger. Levels control how
                much information is emitted during runtime, and relate to
                each other as follows:
                <pre class="d_code">

                    <span class="i">Trace</span> &lt; <span class="i">Info</span> &lt; <span class="i">Warn</span> &lt; <span class="i">Error</span> &lt; <span class="i">Fatal</span> &lt; <span class="i">None</span>
                
</pre>
                That is, if the level is set to Error, only calls to the
                error&#40;&#41; and fatal&#40;&#41; methods will actually produce output:
                all others will be inhibited.</font><br><br>
<font color="black">Note that Log4J is a hierarchical environment, and each
                logger defaults to inheriting a level from its parent.<br><br>
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L191">setLevel</a></span>
<script>explorer.outline.addDecl('setLevel');</script>(Level <span class="funcparam">level</span>, bool <span class="funcparam">force</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">same as setLevel &#40;Level&#41;, but with additional control over 
                whether the children are forced to accept the changed level
                or not. If 'force' is false, then children adopt the parent
                level only if they have their own level set to Level.None</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L199">isEnabled</a></span>
<script>explorer.outline.addDecl('isEnabled');</script>(Level <span class="funcparam">level</span> = Level.Fatal); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Is this logger enabled for the provided level?</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L208">isAdditive</a></span>
<script>explorer.outline.addDecl('isAdditive');</script>(); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return whether this logger uses additive appenders or not. 
                See setAdditive&#40;&#41;.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L219">setAdditive</a></span>
<script>explorer.outline.addDecl('setAdditive');</script>(bool <span class="funcparam">enabled</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Specify whether or not this logger has additive behaviour.
                This is enabled by default, and causes a logger to invoke
                all appenders within its ancestry &#40;until an ancestor is
                found with an additive attribute of false&#41;.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L237">addAppender</a></span>
<script>explorer.outline.addDecl('addAppender');</script>(Appender <span class="funcparam">appender</span>); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add an appender to this logger. You may add multiple
                appenders to appropriate loggers, and each of them 
                will be invoked for that given logger, and for each
                of its child loggers &#40;assuming isAdditive&#40;&#41; is true
                for those children&#41;. Note that multiple instances
                of the same appender, regardless of where they may
                reside within the tree, are not invoked at runtime.
                That is, only one from a set of identical loggers 
                will execute.</font><br><br>
<font color="black">Use clearAppenders&#40;&#41; to remove all from a given logger.
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Logger <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L245">clearAppenders</a></span>
<script>explorer.outline.addDecl('clearAppenders');</script>(); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove all appenders from this logger.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>TimeSpan <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/log/Logger.d?rev=3461#L253">runtime</a></span>
<script>explorer.outline.addDecl('runtime');</script>(); [abstract]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Get number of milliseconds since this application started</font><br><br></dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2004 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sun Jun  8 17:12:54 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>